/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * autenticar.java
 *
 * Created on 2/02/2011, 10:54:42 AM
 */

package sie_invdis;

import javax.swing.*;
import javax.swing.JOptionPane;
import java.sql.*;
import org.jdesktop.application.Action;

import org.jdom.*;
import org.jdom.output.*;
import org.jdom.input.*;
import java.io.*;
import java.util.*;
/**
 *
 * @author Michelle
 */
public class autenticar extends javax.swing.JDialog {

     private javax.swing.table.DefaultTableModel jtable_tiendas;
     private JTable tabla_ti = new javax.swing.JTable();;
     int autorizado=0;
    /** Creates new form autenticar */
    public autenticar(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.encabezadotabla();
        initComponents();
        tabla_ti.setModel(this.jtable_tiendas);
        tabla_ti.setName("tabla_ti"); // NOI18N

      this.jPanel2.setVisible(false);
        this.jtf_usua.requestFocus();
        this.jep_invitacion.setText("<html><head></head><body><p style=\"margin-top: 0\"><img src=\" http://"+this.jtf_sitio1.getText()+"/javaweb/imagenespuntoventa/michelle.gif\" width=\"200\" height=\"60\" border=\"0\" alt=\"Foto\"></img></p></body></html>");
        //this.jep_invitacion.setText("<html><head></head><body><p style=\"margin-top: 0\"><img src=\" http://"+this.jtf_sitio1.getText()+"/javaweb/imagenespuntoventa/repre.jpg\" width=\"200\" height=\"60\" border=\"0\" alt=\"Foto\"></img></p></body></html>");
        //this.datos_checarauto();
        if(autorizado==1)
            {
                this.jbtn_checar.setVisible(false);
            }
        else
            {
                this.jbtn_checar.setVisible(false);
            }
        //System.out.println(this.jep_invitacion.getText());
    }

    private void datos_checarauto()
        {
               try
                    {
                        File archivo = new File(this.jtf_unidaddatos.getText().toUpperCase().replace(":", "")+":/windows/sichecadodatos.xml");
                        if (archivo.exists())
                            {
                                autorizado=1;
                                variables_global.setunidadlocal(this.jtf_unidaddatos.getText().toUpperCase());
                            }
                    }
                    catch (Exception ex)
                        {
                            ex.printStackTrace();
                        }
        }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jbtn_helpayudame = new javax.swing.JButton();
        jbtn_exit = new javax.swing.JButton();
        jbtn_enter = new javax.swing.JButton();
        jpw_contra = new javax.swing.JPasswordField();
        jtf_usua = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jep_invitacion = new javax.swing.JEditorPane();
        jbtn_checar = new javax.swing.JButton();
        jCheckBox1 = new javax.swing.JCheckBox();
        jtf_unidaddatos = new javax.swing.JTextField();
        jtf_sistematitulo = new javax.swing.JTextField();
        jtf_sistemasitiofotos = new javax.swing.JTextField();
        jtf_sistemabdext = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jtf_sitio1 = new javax.swing.JTextField();
        jtf_sitioexterno = new javax.swing.JTextField();
        jtf_basedatos = new javax.swing.JTextField();
        jtf_carpetaservidor = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jmni_checador = new javax.swing.JMenuItem();
        jmni_host = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(autenticar.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(347, 180));

        jbtn_helpayudame.setIcon(resourceMap.getIcon("jbtn_helpayudame.icon")); // NOI18N
        jbtn_helpayudame.setText(resourceMap.getString("jbtn_helpayudame.text")); // NOI18N
        jbtn_helpayudame.setName("jbtn_helpayudame"); // NOI18N
        jbtn_helpayudame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_helpayudameActionPerformed(evt);
            }
        });

        jbtn_exit.setIcon(resourceMap.getIcon("jbtn_exit.icon")); // NOI18N
        jbtn_exit.setText(resourceMap.getString("jbtn_exit.text")); // NOI18N
        jbtn_exit.setName("jbtn_exit"); // NOI18N
        jbtn_exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_exitActionPerformed(evt);
            }
        });

        jbtn_enter.setIcon(resourceMap.getIcon("jbtn_enter.icon")); // NOI18N
        jbtn_enter.setText(resourceMap.getString("jbtn_enter.text")); // NOI18N
        jbtn_enter.setName("jbtn_enter"); // NOI18N
        jbtn_enter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_enterActionPerformed(evt);
            }
        });

        jpw_contra.setText(resourceMap.getString("jpw_contra.text")); // NOI18N
        jpw_contra.setName("jpw_contra"); // NOI18N
        jpw_contra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jpw_contraActionPerformed(evt);
            }
        });

        jtf_usua.setText(resourceMap.getString("jtf_usua.text")); // NOI18N
        jtf_usua.setName("jtf_usua"); // NOI18N
        jtf_usua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_usuaActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jep_invitacion.setContentType(resourceMap.getString("jep_invitacion.contentType")); // NOI18N
        jep_invitacion.setEditable(false);
        jep_invitacion.setText(resourceMap.getString("jep_invitacion.text")); // NOI18N
        jep_invitacion.setName("jep_invitacion"); // NOI18N
        jScrollPane1.setViewportView(jep_invitacion);

        jbtn_checar.setIcon(resourceMap.getIcon("jbtn_checar.icon")); // NOI18N
        jbtn_checar.setText(resourceMap.getString("jbtn_checar.text")); // NOI18N
        jbtn_checar.setToolTipText(resourceMap.getString("jbtn_checar.toolTipText")); // NOI18N
        jbtn_checar.setName("jbtn_checar"); // NOI18N
        jbtn_checar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_checarActionPerformed(evt);
            }
        });

        jCheckBox1.setSelected(true);
        jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
        jCheckBox1.setName("jCheckBox1"); // NOI18N
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jtf_unidaddatos.setText(resourceMap.getString("jtf_unidaddatos.text")); // NOI18N
        jtf_unidaddatos.setName("jtf_unidaddatos"); // NOI18N
        jtf_unidaddatos.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_basedatos.setText("SIE");
        //jtf_sitio.setText("localhost/SIE");
        jtf_unidaddatos.setVisible(false);

        jtf_sistematitulo.setText(resourceMap.getString("jtf_sistematitulo.text")); // NOI18N
        jtf_sistematitulo.setName("jtf_sistematitulo"); // NOI18N
        jtf_sistematitulo.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_basedatos.setText("SIE");
        //jtf_sitio.setText("localhost/SIE");
        jtf_sistematitulo.setVisible(false);

        jtf_sistemasitiofotos.setText(resourceMap.getString("jtf_sistemasitiofotos.text")); // NOI18N
        jtf_sistemasitiofotos.setName("jtf_sistemasitiofotos"); // NOI18N
        jtf_sistemasitiofotos.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_basedatos.setText("SIE");
        //jtf_sitio.setText("localhost/SIE");
        jtf_sistemasitiofotos.setVisible(false);

        jtf_sistemabdext.setText(resourceMap.getString("jtf_sistemabdext.text")); // NOI18N
        jtf_sistemabdext.setName("jtf_sistemabdext"); // NOI18N
        jtf_sistemabdext.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_basedatos.setText("SIE");
        //jtf_sitio.setText("localhost/SIE");
        jtf_sistemabdext.setVisible(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtf_usua, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jtf_unidaddatos, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(21, 21, 21)
                            .addComponent(jtf_sistemasitiofotos, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jpw_contra, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jCheckBox1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtf_sistematitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jtf_sistemabdext, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(3, 3, 3)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jbtn_checar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtn_helpayudame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtn_exit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtn_enter, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jtf_usua, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtf_unidaddatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jpw_contra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jtf_sistematitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jtf_sistemabdext, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jCheckBox1)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jtf_sistemasitiofotos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jbtn_enter, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_exit, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_helpayudame, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_checar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel2.setName("jPanel2"); // NOI18N

        jtf_sitio1.setText(resourceMap.getString("jtf_sitio1.text")); // NOI18N
        jtf_sitio1.setName("jtf_sitio1"); // NOI18N
        jtf_sitio1.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_sitio.setText("localhost/SIE");

        jtf_sitioexterno.setText(resourceMap.getString("jtf_sitioexterno.text")); // NOI18N
        jtf_sitioexterno.setName("jtf_sitioexterno"); // NOI18N
        jtf_sitioexterno.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_sitio.setText("localhost/SIE");
        jtf_sitioexterno.setVisible(false);

        jtf_basedatos.setText(resourceMap.getString("jtf_basedatos.text")); // NOI18N
        jtf_basedatos.setName("jtf_basedatos"); // NOI18N
        jtf_basedatos.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_basedatos.setText("SIE");
        //jtf_sitio.setText("localhost/SIE");
        //jtf_basedatos.setVisible(false);

        jtf_carpetaservidor.setText(resourceMap.getString("jtf_carpetaservidor.text")); // NOI18N
        jtf_carpetaservidor.setName("jtf_carpetaservidor"); // NOI18N
        jtf_carpetaservidor.setPreferredSize(new java.awt.Dimension(59, 20));
        //jtf_basedatos.setText("SIE");
        //jtf_sitio.setText("localhost/SIE");
        jtf_carpetaservidor.setVisible(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jtf_sitio1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_sitioexterno, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_basedatos, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_carpetaservidor, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jtf_sitio1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jtf_basedatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jtf_sitioexterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jtf_carpetaservidor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem1.setIcon(resourceMap.getIcon("jMenuItem1.icon")); // NOI18N
        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jmni_checador.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.ALT_MASK));
        jmni_checador.setIcon(resourceMap.getIcon("jmni_checador.icon")); // NOI18N
        jmni_checador.setText(resourceMap.getString("jmni_checador.text")); // NOI18N
        jmni_checador.setName("jmni_checador"); // NOI18N
        jmni_checador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_checadorActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_checador);

        jmni_host.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
        jmni_host.setText(resourceMap.getString("jmni_host.text")); // NOI18N
        jmni_host.setName("jmni_host"); // NOI18N
        jmni_host.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_hostActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_host);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_enterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_enterActionPerformed
        // TODO add your handling code here:
        String texto = this.jtf_usua.getText();
        String texto2 = this.jpw_contra.getText();

        if((!("".equals(texto))) &&(!("".equals(texto2))))
            {
                this.ingresar();
            }
        else
            {
                this.jtf_usua.requestFocus();
            }
        //this.dispose();
}//GEN-LAST:event_jbtn_enterActionPerformed

    private void jbtn_exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_exitActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Realmente Desea Salir?")==0)
            {
               System.exit(0);// para cerrar la aplicacion
            }
}//GEN-LAST:event_jbtn_exitActionPerformed

    private void jtf_usuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_usuaActionPerformed
        this.jpw_contra.requestFocus();        // TODO add your handling code here:
    }//GEN-LAST:event_jtf_usuaActionPerformed

    private void jpw_contraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jpw_contraActionPerformed
                // TODO add your handling code here:
        String texto = this.jtf_usua.getText();
        String texto2 = this.jpw_contra.getText();
        if((!("".equals(texto))) &&(!("".equals(texto2))))
            {
                this.ingresar();
            }
        else
            {
                this.jtf_usua.requestFocus();
            }

        
    }//GEN-LAST:event_jpw_contraActionPerformed

    private void jbtn_helpayudameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_helpayudameActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(null," 1.-Sistema de nivel Administrativo ingreso de Gerentes,supervision,almacen etc\n 2.- El sistema Distingue de Mayusculas y Minusculas(ejemplo:\"usuario\" no es igual que \"Usuario\" )\n 3:Respecto al punto 2 si a intentado entrar al sistema y no lo logra verifique el estado de su teclado\n 4.- Si no puede ingresar Comuniquese con su administrador", "Ingreso Al Sistema: Ayuda",1);
        this.jtf_usua.requestFocus();
}//GEN-LAST:event_jbtn_helpayudameActionPerformed

    private void jbtn_checarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_checarActionPerformed
        // TODO add your handling code here:
        //this.jtf_usua.setText("asistencia");
        //this.jpw_contra.setText("invitado");
        //this.jbtn_enterActionPerformed(evt);
        
        variables_global.setBd(this.jtf_basedatos.getText());
        variables_global.setHost(this.jtf_sitio1.getText());
        variables_global.setbdLogin("monitoreoinventario");
        variables_global.setbdPassword("Monitoreosie+=11");
        variables_global.setHostexterno(this.jtf_sitioexterno.getText());
        variables_global.setBdinvitado(this.jtf_sistemabdext.getText());
        variables_global.setnivelusu(6);
         this.dispose();
       
       
}//GEN-LAST:event_jbtn_checarActionPerformed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        // TODO add your handling code here:
        variables_global.setveravisos(0);
        this.jpw_contra.requestFocus();
        this.jbtn_enterActionPerformed(evt);
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        this.jbtn_exitActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        this.jbtn_exitActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jmni_checadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_checadorActionPerformed
        // TODO add your handling code here:
         if(autorizado==1)
            {
                this.jbtn_checarActionPerformed(evt);
            }
        else
            {
                
            }

    }//GEN-LAST:event_jmni_checadorActionPerformed

    private void jmni_hostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_hostActionPerformed
        // TODO add your handling code here:
    
        this.jPanel2.setVisible(true);
    }//GEN-LAST:event_jmni_hostActionPerformed
private void encabezadotabla()
{
    jtable_tiendas=new javax.swing.table.DefaultTableModel();//Creo el modelo
    jtable_tiendas.addColumn("Descripcion");
    jtable_tiendas.addColumn("Id tienda");
    jtable_tiendas.addColumn("esquema");
    jtable_tiendas.addColumn("Cliente");
}


     private void ingresar() {
        // TODO add your handling code here:
        String registros="";
        int nive=0;
        variables_global.setHost(this.jtf_sitio1.getText());
        variables_global.setHostexterno(this.jtf_sitioexterno.getText());
        variables_global.setBd(this.jtf_basedatos.getText());
        variables_global.setLogin(this.jtf_usua.getText());
        variables_global.setPassword(this.jpw_contra.getText());
        variables_global.setcarpetaaplicacion(this.jtf_carpetaservidor.getText());
        variables_global.setHostfotos(this.jtf_sistemasitiofotos.getText());
        variables_global.setDescribeaplicacion(this.jtf_sistematitulo.getText());
        variables_global.setBdinvitado(this.jtf_sistemabdext.getText());
        if (variables_global.getPassword().equals("invitado"))
            {
                variables_global.setbdLogin("monitoreoinventario");
                variables_global.setbdPassword("Monitoreosie+=11");
            }
        else
            {
             variables_global.setbdLogin("distribucion_cruz"); //servidor punta de venta
              variables_global.setbdPassword("p200005li1980");// servidor punto venta
              // variables_global.setbdLogin("postgres");
               //variables_global.setbdPassword("NA0729");
              // variables_global.setbdLogin("postgres"); //servidor y laptop de mayoreo
              // variables_global.setbdPassword("debianpostgres2011"); //servidor y laptop de mayoreo
              //variables_global.setbdLogin("postgres"); //local zaga cruz
              //variables_global.setbdPassword("postgresdebian"); //local zaga cruz
            }


       bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
       ResultSet rs = null;
       ResultSet rs2 = null;
       //llamo almetodo para establecer la conexion
       x.estableceConexion();
        //verifico si marque el error en global
       if (variables_global.getError_ingreso()==-1)
            {
                JOptionPane.showMessageDialog(null,"no se pudo ingresar al sistema", "Error",1);
                this.jtf_usua.setText("");
                this.jpw_contra.setText("");
                this.jtf_usua.requestFocus();
            }
       else
            {
            String texto="select * from x1usuario_autenticov6(5,'"+variables_global.getLogin()+"','"+variables_global.getPassword()+"','','') as (idt integer, ide smallint,iddep smallint,alma smallint,idempleado integer,describetienda character varying(35),desdepa character varying(80),nombre character varying(80),idarea smallint,depaidarea smallint);";
           //String texto="select * from x1usuario_autentico(5,'"+variables_global.getLogin()+"','"+variables_global.getPassword()+"','','') as (idt integer, idempleado integer);";
            System.out.println(texto);
            try
                {
                rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                while (rs.next())
                        {
                        registros="1";
                        nive=rs.getInt(2);
                        variables_global.setnivelusu(nive);
                        variables_global.setalmacen(rs.getInt("alma"));
                        variables_global.setId_empleado(rs.getInt("idempleado"));
                        variables_global.setNombre(rs.getString("nombre"));
                        variables_global.setArea(rs.getInt("idarea"));
                        variables_global.setdepaidarea(rs.getInt("depaidarea"));
                        if ((nive < 3)||(nive == 4)||(nive == 5)||(nive == 6))
                            {
                                variables_global.setcliente_tistribucion("all");
                                variables_global.setidtiendamidescribe("General");
                            }
                        else if ((nive == 3)||(nive == 8))
                            {
                                variables_global.setidtiendami(rs.getInt("idt"));
                                variables_global.setidtiendamidescribe(rs.getString("describetienda"));
                                String damecli="select * from x1usuario_tiendapertenecev3("+Integer.parseInt(rs.getString (1))+") as (idc character varying(12),idti integer,idtipo smallint)";
                                rs2=x.sieuno_executediversosv2(damecli,variables_global.getconexiongral());
                                while (rs2.next())
                                        {
                                            variables_global.setcliente_tistribucion(rs2.getString("idc"));
                                            variables_global.setidtipotienda(rs2.getInt("idtipo"));
                                        }
                            }
                        else
                            {
                                //variables_global.setcliente_tistribucion("vacio");
                            }
                            variables_global.setdepartamento(rs.getString("iddep"));
                            variables_global.setdepartamento_des(rs.getString("desdepa"));
                            System.out.println(registros);
                        }

                }
                catch(Exception e)
                    {
                        System.out.println(e.getMessage());
                    }
               if ((!(registros.equals(""))) && (!(registros.equals("0"))))
                        {
                            try
                                {
                                    rs = x.sieuno_executediversosv2("select * from x1distribucion_tiendas_all() as (tie_descri character varying(35),tie_id integer,tie_desesque character varying(25),idclie character varying(12));",variables_global.getconexiongral());
                                    while (rs.next())
                                        {
                                          jtable_tiendas.addRow(new Object[]{rs.getString("tie_descri"),rs.getString("tie_id"),rs.getString("tie_desesque"),rs.getString("idclie")});
                                          //establesco el nombre de la tienda, porque la funcion no trae el nombre, pendierte mejorar la funcion
                                         
                                        }
                                }
                            catch(Exception e)
                                    {
                                        System.out.println(e.getMessage());
                                    }
                            variables_global.settabla_tiendas(tabla_ti);
                            JOptionPane.showMessageDialog(null,"Bienvenido al "+this.jtf_sistematitulo.getText(),"Sistema Integral:Bienvenida",1);
                            this.dispose();
                        }
                    else
                        {
                            JOptionPane.showMessageDialog(null,"no se pudo ingresar al sistema", "Error",1);
                            this.jtf_usua.setText("");
                            this.jpw_contra.setText("");
                            this.jtf_usua.requestFocus();
                        }
            }
}
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                autenticar dialog = new autenticar(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtn_checar;
    private javax.swing.JButton jbtn_enter;
    private javax.swing.JButton jbtn_exit;
    private javax.swing.JButton jbtn_helpayudame;
    private javax.swing.JEditorPane jep_invitacion;
    private javax.swing.JMenuItem jmni_checador;
    private javax.swing.JMenuItem jmni_host;
    private javax.swing.JPasswordField jpw_contra;
    private javax.swing.JTextField jtf_basedatos;
    private javax.swing.JTextField jtf_carpetaservidor;
    private javax.swing.JTextField jtf_sistemabdext;
    private javax.swing.JTextField jtf_sistemasitiofotos;
    private javax.swing.JTextField jtf_sistematitulo;
    private javax.swing.JTextField jtf_sitio1;
    private javax.swing.JTextField jtf_sitioexterno;
    private javax.swing.JTextField jtf_unidaddatos;
    private javax.swing.JTextField jtf_usua;
    // End of variables declaration//GEN-END:variables

}
